import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;
public class Studenttest {
    public static void main(String[] args) {
        //Student student=new Student();
        ArrayList<Student> lt = new ArrayList<>();
        Studentmange stm = new Studentmange();
        //集合中默认添加一个对象
        lt.add(0, new Student(888, "zhangfei", 30));
        lt.add(1, new Student(999, "guanyu", 33));
        String path = "E:/a.txt";
        File file = new File(path);
        if (file.exists()) {
            stm.StudentInputStream(lt, path);
            System.out.println("读取到的对象存入集合为：" + lt);
        }
        boolean flag = true;
        Scanner sc = new Scanner(System.in);
        while (flag) {
            System.out.println("请输入您要操作的内容：1.添加用户；2.删除用户；3.修改用户；4.查找用户");
            int a = sc.nextInt();
            switch (a) {
                case 1:
                    while (flag) {
                        stm.addStudent(lt);
                        System.out.println("是否继续添加用户(Y/N)：");
                        String h = sc.next();
                        if ("N".equals(h)) {
                            flag = !flag;
                        }
                    }
                case 2:
                    while (flag) {
                        stm.deleteStudent(lt);
                        System.out.println("是否继续删除用户(Y/N)：");
                        String h = sc.next();
                        if ("N".equals(h)) {
                            flag = !flag;
                        }
                    }
                case 3:
                    while (flag) {
                        stm.updateStudent(lt);
                        System.out.println("是否继续修改用户(Y/N)：");
                        String h = sc.next();
                        if ("N".equals(h)) {
                            flag = !flag;
                        }
                    }
                case 4:
                    stm.findAllStudent(lt);
            }
            System.out.println("是否继续返回主菜单（Y/N）");
            String choose = sc.next();
            flag = ("Y".equals(choose)) ? true : false;
        }


        stm.StudentOutputStream(lt);
     }

}
